package com.hzhr.iot.statis.dao;

import com.hzhr.iot.statis.dao.mapper.custom.DeviceDailyGasConsumeEntityCustomMapper;
import com.hzhr.iot.statis.dao.mapper.generator.DeviceDailyGasConsumeEntityMapper;
import com.hzhr.iot.statis.entity.DeviceDailyGasConsumeEntity;
import com.hzhr.iot.statis.entity.ext.DeviceDailyGasConsumeEntityExt;
import com.hzhr.iot.statis.queryModel.custom.DeviceDailyGasConsumeCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class DeviceDailyGasConsumeDao {
    @Autowired
    DeviceDailyGasConsumeEntityMapper deptDailyGasConsumeEntityMapper;
    @Autowired
    DeviceDailyGasConsumeEntityCustomMapper deptDailyGasConsumeEntityCustomMapper;

    public int insert(DeviceDailyGasConsumeEntity record) {
        if (record == null) return 0;
        int changeCount = deptDailyGasConsumeEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(DeviceDailyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = deptDailyGasConsumeEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(DeviceDailyGasConsumeEntity record) {
        if (record == null) return 0;
        int changeCount = deptDailyGasConsumeEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(DeviceDailyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = deptDailyGasConsumeEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public DeviceDailyGasConsumeEntity selectEntity(DeviceDailyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceDailyGasConsumeEntityExt> extList = deptDailyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<DeviceDailyGasConsumeEntity> selectEntityList(DeviceDailyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceDailyGasConsumeEntityExt> extList = deptDailyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<DeviceDailyGasConsumeEntity> entityList = new ArrayList<>();
        for (DeviceDailyGasConsumeEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public DeviceDailyGasConsumeEntityExt selectExt(DeviceDailyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceDailyGasConsumeEntityExt> extList = deptDailyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<DeviceDailyGasConsumeEntityExt> selectExtList(DeviceDailyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceDailyGasConsumeEntityExt> extList = deptDailyGasConsumeEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public int selectCount(DeviceDailyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = deptDailyGasConsumeEntityCustomMapper.selectCount(queryModel);
        return count;
    }
}
